package org.limited.memory.utils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MemoryInfoUtil {

    public static void memoryInfo(){
        Runtime runtime = Runtime.getRuntime();

        // 获取当前JVM的内存信息
        long maxMemory = runtime.maxMemory(); // 最大可用内存
        long totalMemory = runtime.totalMemory(); // 当前已分配内存
        long freeMemory = runtime.freeMemory(); // 当前空闲内存

        log.info("Max Memory:{}",maxMemory / (1024 * 1024) + " MB");
        log.info("Total Memory:{}",totalMemory / (1024 * 1024) + " MB");
        log.info("Free Memory:{}",freeMemory / (1024 * 1024) + " MB");
    }
}
